package com.system.mapper;

import com.order.hit.crossover.platform.common.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Lei
 * @version 0.1
 * @date 2020/9/8
 */
public interface UserMapper {

    @Select("select * from user")
    @Results({
            @Result(property = "userId", column = "userId"),
            @Result(property = "userName", column = "userName"),
            @Result(property = "userPassword", column = "userPassword")
    })
    public List<User> getAlluser();

    @Select("select * from user where userName=#{userName} and userPassword=#{userPassword}")
    @Results({
            @Result(property = "userId", column = "userId"),
            @Result(property = "userName", column = "userName"),
            @Result(property = "userPassword", column = "userPassword")
    })
    public User login(String userName, String userPassword);

    @Select("select * from user where userId=#{id}")
    @Results({
            @Result(property = "userId", column = "userId"),
            @Result(property = "userName", column = "userName"),
            @Result(property = "userPassword", column = "userPassword")
    })
    public User getUserByid(int id);

    @Select("select * from user where userName=#{userName}")
    @Results({
            @Result(property = "userId", column = "userId"),
            @Result(property = "userName", column = "userName"),
            @Result(property = "userPassword", column = "userPassword")
    })
    public User checkuserName(String userName);

    @Insert("insert into user (userId, userName, userPassword) VALUES (#{userId}, #{userName}, #{userPassword})")
    @Results({
            @Result(property = "userId", column = "userId"),
            @Result(property = "userName", column = "userName"),
            @Result(property = "userPassword", column = "userPassword")
    })
    public void insertUser(User user);
}
